package com.tanhua.server.controller;

import com.tanhua.server.service.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/baidu")
public class BaiduController {

    @Autowired
    private BaiduService baiduService;

    /**
     * 上报地理信息
     * */
    @PostMapping("/location")
    public ResponseEntity location(@RequestBody Map map){
        //维度
        String s1 = map.get("latitude").toString();
        Double latitude = Double.valueOf(s1);
        //经度
        String s2 = map.get("longitude").toString();
        Double longitude = Double.valueOf(s2);
        //位置描述
        String addrStr = map.get("addrStr").toString();
        baiduService.location(latitude,longitude,addrStr);
        return ResponseEntity.ok(null);
    }

}
